﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EA.Common
{
   public class Converts
    {
        public static int getValueInteger(String name, int index, DataTable table)
        {
            return table.Rows[index][name] == DBNull.Value ? Constant.INTEGER_NULL : (int)table.Rows[index][name];
        }

        public static Double getValueDouble(String name, int index, DataTable table)
        {
            return table.Rows[index][name] == DBNull.Value ? Constant.DOUBLE_NULL : (Double)table.Rows[index][name];
        }

        public static Decimal getValueDecimal(String name, int index, DataTable table)
        {
            return table.Rows[index][name] == DBNull.Value ? Constant.DOUBLE_NULL : (Decimal)table.Rows[index][name];
        }

        public static DateTime getValueDateTime(String name, int index, DataTable table)
        {
            return table.Rows[index][name] == DBNull.Value ? new DateTime(1, 1, 1, 1, 1, 1) : (DateTime)table.Rows[index][name];
        }

        public static String getValueString(String name, int index, DataTable table)
        {
            return table.Rows[index][name] == DBNull.Value ? "" : (String)table.Rows[index][name];
        }
    }
}
